$OpenBSD: patch-dbdimp_c,v 1.1 2015/01/17 00:42:16 giovanni Exp $
Fix a use-after-free if my_login fails

--- dbdimp.c.orig	Mon Dec  8 09:44:50 2014
+++ dbdimp.c	Sun Dec 28 00:40:38 2014
@@ -2061,8 +2061,11 @@ static int my_login(pTHX_ SV* dbh, imp_dbh_t *imp_dbh)
   result = mysql_dr_connect(dbh, imp_dbh->pmysql, mysql_socket, host, port, user,
 			  password, dbname, imp_dbh) ? TRUE : FALSE;
   if (fresh && !result) {
+      do_error(dbh, mysql_errno(imp_dbh->pmysql),
+              mysql_error(imp_dbh->pmysql) ,mysql_sqlstate(imp_dbh->pmysql));
       /* Prevent leaks, but do not free in case of a reconnect. See #97625 */
       Safefree(imp_dbh->pmysql);
+      imp_dbh->pmysql = NULL;
   }
   return result;
 }
@@ -4953,9 +4956,11 @@ int mysql_db_reconnect(SV* h)
    */
   if (!dbd_db_disconnect(h, imp_dbh) || !my_login(aTHX_ h, imp_dbh))
   {
-    do_error(h, mysql_errno(imp_dbh->pmysql), mysql_error(imp_dbh->pmysql),
+    if(!imp_dbh->pmysql) {
+    	do_error(h, mysql_errno(imp_dbh->pmysql), mysql_error(imp_dbh->pmysql),
              mysql_sqlstate(imp_dbh->pmysql));
-    memcpy (imp_dbh->pmysql, &save_socket, sizeof(save_socket));
+    	memcpy (imp_dbh->pmysql, &save_socket, sizeof(save_socket));
+    }
     ++imp_dbh->stats.auto_reconnects_failed;
     return FALSE;
   }
